﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HttpClientStudy.UnitTest
{
    public class HttpErrorTest : IDisposable
    {
        private readonly ITestOutputHelper _logger;
        private readonly HttpError _httpError = new HttpError();

        public HttpErrorTest(ITestOutputHelper outputHelper)
        {
            _logger = outputHelper;
        }

        [Fact]
        public async Task UnknownHost_Test()
        {
            Func<Task> func = _httpError.UnknownHostAsync;

            await Assert.ThrowsAsync<HttpRequestException>(func);
        }

        [Fact]
        public async Task NoService_Test()
        {
            Func<Task> func = _httpError.NoServiceAsync;

            await Assert.ThrowsAsync<HttpRequestException>(func);
        }

        [Fact]
        public async Task Http404_Test()
        {
            var code = await _httpError.Http404Async();

            Assert.Equal(HttpStatusCode.NotFound, code);
        }

        [Fact]
        public async Task Http500_Test()
        {
            var code = await _httpError.Http500Async();

            Assert.Equal(HttpStatusCode.InternalServerError, code);
        }

        public void Dispose()
        {

        }
    }
}
